<?php

	function insertSystem(
	$p_name
	, $p_description
	, $p_value
	) {
		mysql_query("
				INSERT INTO TB_SYSTEM(
					NAME
						,DESCRIPTION
						,VALUE
		
				)VALUES(
					'" . $p_name . "'
						,'" . $p_description . "'
						,'" . $p_value . "'
		
				)	
			") or die(mysql_error());
		return mysql_insert_id();
	}

	function updateSystem(
	$p_id
	, $p_name
	, $p_description
	, $p_value
	) {
		mysql_query("
				UPDATE TB_SYSTEM 
				SET
					NAME='" . $p_name . "'
						,DESCRIPTION='" . $p_description . "'
						,VALUE='" . $p_value . "'
		
				WHERE ID =  '" . $p_id . "'
			");
	}

	function getAllSystem($p_where_clause, $p_offset, $p_num_row, $p_order_by=" ID DESC ") {
		$rs = mysql_query("
			SELECT 
				ID
					,NAME
					,DESCRIPTION
					,VALUE

			FROM TB_SYSTEM	
			WHERE 1 " . $p_where_clause . "		
			ORDER BY " . $p_order_by . "
			LIMIT " . $p_offset . "," . $p_num_row . "
			") or die(mysql_error());
		return $rs;
	}

	function getSingerSystem($p_id) {
		$rs = mysql_query("
			SELECT 
				ID
					,NAME
					,DESCRIPTION
					,VALUE

			FROM TB_SYSTEM	
			WHERE ID =  '" . $p_id . "'		
			") or die(mysql_error());
		return $rs;
	}

	function createDifineSystemParameter() {
		$rs = getAllSystem("", 0, 1000);
		while ($arr = mysql_fetch_array($rs, MYSQL_NUM)) {
			define($arr[1], $arr[3]);
		}
	}